package com.my.study.utils;

import cn.hutool.core.builder.CompareToBuilder;

/**
 * @author: yidujun
 * @create: 2021/06/30 11:12
 */
public class Money implements Comparable<Money> {
    private String rate;
    private double count;

    public Money() {
    }

    public Money(String rate, double count) {
        this.rate = rate;
        this.count = count;
    }

    public String getRate() {
        return rate;
    }

    public void setRate(String rate) {
        this.rate = rate;
    }

    public double getCount() {
        return count;
    }

    public void setCount(double count) {
        this.count = count;
    }

    @Override
    public int compareTo(Money o) {
        return compare(this, o);
    }

    public static int compare(Money self, Money o) {
        return new CompareToBuilder()
                .append(self.rate, o.rate)
                .append(self.count, o.count)
                .toComparison();
    }

    @Override
    public String toString() {
        return "Money{" +
                "rate='" + rate + '\'' +
                ", count=" + count +
                '}';
    }
}
